package caiziyou.com.designpattern.composite;

import java.util.ArrayList;
import java.util.List;

public abstract class OraganitionComponent {
	
	private List<OraganitionComponent> children = new ArrayList<>();

	private String name;
	private String des;

	public OraganitionComponent(String name, String des) {
		super();
		this.name = name;
		this.des = des;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}

	public void add(OraganitionComponent e) {
		children.add(e);
	}

	public void remove(OraganitionComponent e) {
		children.remove(e);
	}

	public List<OraganitionComponent> getChildren() {
		
		return children;
	}

	public void print() {
		System.out.println(getName() +"\t" + getDes());
		System.out.println("----------------------------------------");
		for (int i = 0; i < children.size(); i++) {
			children.get(i).print();
		}
	}
}
